#include "libLUI_in.h"

#if 0
int OpenMouseDevice()
{
	char		path_device_name[ 256 + 1 ] ;
	int		fd ;
	
	memset( path_device_name , 0x00 , sizeof(path_device_name) );
	snprintf( path_device_name , sizeof(path_device_name) , "/dev/input/mice" );
	fd = open( path_device_name , O_RDONLY ) ;
	if( fd == -1 )
		return -4;
	
	return fd;
}
#endif

int OpenMouseDevice( char *p_path_device_name , int path_device_name_bufsize )
{
	char		device_name[ 256 + 1 ] ;
	char		path_device_name[ 256 + 1 ] ;
	int		fd ;
	int		nret = 0 ;
	
	memset( device_name , 0x00 , sizeof(device_name) );
	nret = GetDeviceName( "mouse" , device_name , sizeof(device_name) ) ;
	if( nret < 0 )
		return nret;
	memset( path_device_name , 0x00 , sizeof(path_device_name) );
	snprintf( path_device_name , sizeof(path_device_name) , "/dev/input/%s" , device_name );
	
	fd = open( path_device_name , O_RDONLY ) ;
	if( fd == -1 )
		return -4;
	
	if( p_path_device_name )
	{
		snprintf( p_path_device_name , path_device_name_bufsize , "%s" , path_device_name );
	}
	
	return fd;
}

void CloseMouseDevice( int fd )
{
	close( fd );
	return;
}

